package org.jeecg.modules.paycenter.enums;

import org.apache.commons.lang.StringUtils;
import org.jeecg.common.exception.JeecgBootException;

import java.util.HashMap;
import java.util.Map;

/**
 * 支付单据类型 1支付运费、尾款  6预付运费 7分段预付运费   8支付计划首付 9支付计划到付
 */
public enum BillTypeEnum {
    PAY("1"), //支付运费、尾款
    PRE_PAY("6"), //预付运费
    SUB_PAY("7"), //分段预付运费
    PLAN_PAY_SHOUFU("8"),//支付计划首付
    PLAN_PAY_DAOFU("9"),//支付计划到付
    ;
    public final String value;
    private static Map<String, BillTypeEnum> _billTypesMap = new HashMap<>();

    BillTypeEnum(String billType) {
        this.value = billType;
    }

    static {
        for (BillTypeEnum item : BillTypeEnum.values()) {
            _billTypesMap.put(item.value, item);
        }
    }

    public static BillTypeEnum getBillTypeEnum(String billType) {
        if (StringUtils.isEmpty(billType)) {
            throw new JeecgBootException("单据类型错误");
        }
        BillTypeEnum billTypeEnum = _billTypesMap.get(billType);
        if (billTypeEnum == null) {
            throw new JeecgBootException("单据类型错误");
        }
        return billTypeEnum;
    }
}
